home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 2
/
Gold Medal Software Volume 2 (Gold Medal) (1994).iso
/
windows
/
win31
/
macsyma.arj
/
MACSDEMO.EXE
/
NEWTON.OUT
< prev
next >
Wrap
Text File
|
1993-09-14
|
6KB
|
126 lines
(c1) /* Demo file for the NEWTON Iteration package. */
(if get('newton,'version)=false then load(newton),showtime:true)$
C:\MACSD2B\share\NEWTON.fas being loaded.
Time= 599 msecs
(c2) /* Univariate Newton method, in single, double, and bigfloat arithmetic. */
(remvalue(x,y,z),eq:tan(x)-1/x);
Time= 109 msecs
|$label(0,15,Times New Roman,$(d2$))tan$paren(x)$hinge()$in( - )$q(1,x)
(c3) newton(eq,x,1.0);
C:\MACSD2B\share\invert.fas being loaded.
Time= 490 msecs
|$label(0,15,Times New Roman,$(d3$))$open([)x$hinge()$in( = )0.86033$close(])
(c4) newton_iteration_counter;
Time= 0 msecs
|$label(0,15,Times New Roman,$(d4$))4
(c5) newton(eq,x,1.0d0);
Time= 59 msecs
|$label(0,15,Times New Roman,$(d5$))$open([)x$hinge()$in( = )0.86033359041178d0$close(])
(c6) newton_iteration_counter;
Time= 0 msecs
|$label(0,15,Times New Roman,$(d6$))4
(c7) newton(eq,x,1.0b0);
Time= 1489 msecs
|$label(0,15,Times New Roman,$(d7$))$open([)x$hinge()$in( = )$num(8.603335904117902b-1)$close(])
(c8) newton_iteration_counter;
Time= 0 msecs
|$label(0,15,Times New Roman,$(d8$))4
(c9) /* When VERBOSE:TRUE, NEWTON prints the estimated solution after each iteration. */
newton(eq,x,1.0d0),verbose:true;
|$label(0,15,Times New Roman,$(e9$))$open([)x$hinge()$in( = )1.0d0$close(])
|$label(0,15,Times New Roman,$(e10$))$open([)x$hinge()$in( = )0.87404692032192d0$close(])
|$label(0,15,Times New Roman,$(e11$))$open([)x$hinge()$in( = )0.86040016299096d0$close(])
|$label(0,15,Times New Roman,$(e12$))$open([)x$hinge()$in( = )0.86033359041178d0$close(])
Time= 659 msecs
|$label(0,15,Times New Roman,$(d12$))$open([)x$hinge()$in( = )0.86033359041178d0$close(])
(c13) /* Multivariate Newton method. */
eqs:[x^2+y^2-2,(x-1)^2+y^2=2];
Time= 0 msecs
|$label(0,15,Times New Roman,$(d13$))$open([)$sup(y,2)$hinge()$in( + )$sup(x,2)$hinge()$in( - )2$ina($, )$hinge()$sup(y,2)$hinge()$in( + )$sup($paren(x$in( - )1,$(,$)),2)$hinge()$in( = )2$close(])
(c14) sfloat(solve(%));
C:\MACSD2B\library1\algsys.fas being loaded.
C:\MACSD2B\library1\grobner.fas being loaded.
Time= 2639 msecs
|$label(0,15,Times New Roman,$(d14$))$open([)$open([)y$hinge()$in( = )$in( - )1.32288$ina($, )$hinge()x$hinge()$in( = )0.5$close(])$ina($, )$hinge()$open([)y$hinge()$in( = )1.32288$ina($, )$hinge()x$hinge()$in( = )0.5$close(])$close(])
(c15) newton(eqs,[x,y],[1.0,1.0]);
C:\MACSD2B\share\blinalgl.fas being loaded.
Time= 539 msecs
|$label(0,15,Times New Roman,$(d15$))$open([)x$hinge()$in( = )0.5$ina($, )$hinge()y$hinge()$in( = )1.32288$close(])
(c16) newton_iteration_counter;
Time= 0 msecs
|$label(0,15,Times New Roman,$(d16$))5
(c17) /* Compare times and number of iterations when
jacobian is evaluated only at the beginning. */
newton(eqs,[x,y],[1.0,1.0]),newton_eval_jacobian:0;
Time= 929 msecs
|$label(0,15,Times New Roman,$(d17$))$open([)x$hinge()$in( = )0.5$ina($, )$hinge()y$hinge()$in( = )1.32288$close(])
(c18) newton_iteration_counter;
Time= 0 msecs
|$label(0,15,Times New Roman,$(d18$))14
(c19) /* Compare times and number of iterations when
jacobian is re-evaluated on only some iterations. */
newton(eqs,[x,y],[1.0,1.0]),newton_eval_jacobian:2;
Time= 329 msecs
|$label(0,15,Times New Roman,$(d19$))$open([)x$hinge()$in( = )0.5$ina($, )$hinge()y$hinge()$in( = )1.32288$close(])
(c20) newton_iteration_counter;
Time= 0 msecs
|$label(0,15,Times New Roman,$(d20$))6
(c21) /* Multivariate Newton method with complex starting point. */
eqs:[x^2+y^2=1,x^2-y^2=2];
Time= 0 msecs
|$label(0,15,Times New Roman,$(d21$))$open([)$sup(y,2)$hinge()$in( + )$sup(x,2)$hinge()$in( = )1$ina($, )$hinge()$sup(x,2)$hinge()$in( - )$sup(y,2)$hinge()$in( = )2$close(])
(c22) sfloat(solve(%));
Time= 819 msecs
|$label(0,15,Times New Roman,$(d22$))$open([)$open([)y$hinge()$in( = )$in( - )0.70711$in( )$italictext(i)$ina($, )$hinge()x$hinge()$in( = )$in( - )1.22474$close(])$ina($, )$hinge()$open([)y$hinge()$in( = )0.70711$hinge()$in( )$italictext(i)$ina($, )$hinge()x$hinge()$in( = )$in( - )1.22474$close(])$ina($, )$hinge()$open([)y$hinge()$in( = )$in( - )0.70711$in( )$italictext(i)$ina($, )$hinge()x$hinge()$in( = )1.22474$close(])$ina($, )$hinge()$open([)y$hinge()$in( = )0.70711$hinge()$in( )$italictext(i)$ina($, )$hinge()x$hinge()$in( = )1.22474$close(])$close(])
(c23) newton(eqs,[x,y],[1.0,1.0*%i]);
Time= 659 msecs
|$label(0,15,Times New Roman,$(d23$))$open([)x$hinge()$in( = )1.22474$ina($, )$hinge()y$hinge()$in( = )0.70711$hinge()$in( )$italictext(i)$close(])
(c24) newton_iteration_counter;
Time= 0 msecs
|$label(0,15,Times New Roman,$(d24$))5
(c25) /* Do a 3-by-3 problem. */
eq1:sin (x) + y^2 + log(z) = 7;
Time= 49 msecs
|$label(0,15,Times New Roman,$(d25$))log$paren(z)$hinge()$in( + )$sup(y,2)$hinge()$in( + )sin$paren(x)$hinge()$in( = )7
(c26) eq2:3*x + 2^y - z^3 = -1;
Time= 0 msecs
|$label(0,15,Times New Roman,$(d26$))$in( - )$sup(z,3)$hinge()$in( + )$sup(2,y)$hinge()$in( + )3$in( )x$hinge()$in( = )$in( - )1
(c27) eq3:x^2 + y^2 + z^3 = 5;
Time= 0 msecs
|$label(0,15,Times New Roman,$(d27$))$sup(z,3)$hinge()$in( + )$sup(y,2)$hinge()$in( + )$sup(x,2)$hinge()$in( = )5
(c28) newton([eq1,eq2,eq3],[x,y,z],[1/2+2*%i,2-%i,2+%i/2]);
Time= 15549 msecs
|$label(0,15,Times New Roman,$(d28$))$open([)x$hinge()$in( = )2.36119$in( )$italictext(i)$hinge()$in( + )0.33996$ina($, )$hinge()y$hinge()$in( = )2.39276$hinge()$in( - )1.0728$in( )$italictext(i)$ina($, )$hinge()z$hinge()$in( = )0.34026$in( )$italictext(i)$hinge()$in( + )1.86956$close(])
(c29) /* Cleanup */
(remvalue(eq,eq1,eq2,eq3,eqs),reset(showtime))$